package org.com.ashen.service.service.smssendlogmanage.sms.manage.smsreport;

import org.com.ashen.dal.dataobject.SmsReport;
import org.com.ashen.dal.mapper.SmsReportMapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class SmsReportServiceImpl {
    private static ApplicationContext applicationContext;

    public static List<SmsReport> selectOneReport(String smsId){
        applicationContext = new ClassPathXmlApplicationContext(new String[]{"application.xml"});
		SmsReportMapper smsReportMapper= (SmsReportMapper) applicationContext.getBean("smsReportMapper");
        List<SmsReport> smsReport = smsReportMapper.selectOne(smsId);
        if(smsReport==null){
            return new ArrayList<>();
        }else {
            return smsReport;
        }
    }

    public static int insert(SmsReport smsReport){
        applicationContext = new ClassPathXmlApplicationContext(new String[]{"application.xml"});
        SmsReportMapper smsReportMapper= (SmsReportMapper) applicationContext.getBean("smsReportMapper");
        int insertRes = smsReportMapper.insert(smsReport);
        return insertRes;
    }

}
